package train;

import java.util.*;

public class DAY619 {
    public static void main(String[] args) {
        int[] a={4,1,2,1,2};
         System.out.println(strStr(a));
    }
    //两数组拼接到一起
    public static int[] sum(int[] nums1,int m,int[] nums2,int n){
       int[] a=new int[m+n];
       int i=0,j=0,k=0;
       while(i<m&&j<n){
          if(nums1[i]<nums2[j]){
              a[k]=nums1[i];
              i++;
          }else {
              a[k]=nums2[j];
              j++;
          }
          k++;
       }
       if(i==m){
           for (int l = j; l <n ; l++) {
               a[k]=nums2[l];
               k++;
           }
       } else{
           for (int l = i; l < m; l++) {
               a[k]=nums1[l];
               k++;
           }
       }
        for (int l = 0; l < a.length; l++) {
            nums1[l]=a[l];
        }
    return nums1;

    }

    //罗马数字转数字
    public static int generate(String s){
      int sum=0;
      String b="IVXLCDM";
        for (int i = 1; i < s.length();i=i+2 ) {
            int i1 = b.indexOf(s.charAt(i));
            int i2 = b.indexOf(s.charAt(i-1));
            if(i2<i1) {
                sum+=change(s.charAt(i))-change(s.charAt(i-1));
            }
            else {
                sum+=change(s.charAt(i-1));
                i=i-1;
            }
        }
        if(s.length()==1){
            return change(s.charAt(0));
        } else {
            if (b.indexOf(s.charAt(s.length() - 1)) <= b.indexOf(s.charAt(s.length() - 2)))
                sum = sum + change(s.charAt(s.length() - 1));
            return sum;
        }
    }
    public static int change(Character a){
        switch (a){
            case 'I': return 1;
            case 'V': return 5;
            case 'X':return 10;
            case 'L':return 50;
            case 'C':return 100;
            case 'D':return 500;
            case 'M':return 1000;
            default: return 0;
        }
    }

    //求三角形最大周长
    public static  int largerP(int x,int y,int[][] points){
        int k=-1;
        int a=10000;
        for (int i = 0; i < points.length; i++) {
            if(points[i][0]==x||points[i][1]==y){
                int mid=Math.abs(points[i][0]-x)+Math.abs(points[i][1]-y);
                if(a>mid){
                    a=mid;
                    k=i;
                }
            }
        }
        return k;
    }



    public static int strStr (int[] nums) {
        Arrays.sort(nums);
        for (int num : nums) {
            System.out.println("num = " + num);
        }

        for (int i = 0; i < nums.length - 1; i=i+2) {
           if(nums[i]!=nums[i+1]) return nums[i];

        }
        return 0;
    }
    }

